package com.ccz.demo.design.state;

import com.ccz.demo.design.state.event.EditStatus;
import com.ccz.demo.design.state.event.PassStatus;
import com.ccz.demo.design.state.event.RefuseStatus;
import lombok.extern.slf4j.Slf4j;

import java.util.HashMap;
import java.util.Map;

public class StatusHandler {

    private Map<Enum<ActivityStatus>, AbstractStatus> statusMap = new HashMap<>();

    public StatusHandler() {
        statusMap.put(ActivityStatus.EDIT, new EditStatus());
        statusMap.put(ActivityStatus.PASS, new PassStatus());
        statusMap.put(ActivityStatus.REFUSE, new RefuseStatus());
    }

    public Result checkPass(String id, Enum<ActivityStatus> currentStatus) {
        return statusMap.get(currentStatus).checkPass(id, currentStatus);
    }

    public Result checkRefuse(String id, Enum<ActivityStatus> currentStatus) {
        return statusMap.get(currentStatus).checkRefuse(id, currentStatus);
    }

    public Result activityFinish(String id, Enum<ActivityStatus> currentStatus) {
        return statusMap.get(currentStatus).activityFinish(id, currentStatus);
    }

    public Result activityCancel(String id, Enum<ActivityStatus> currentStatus) {
        ActivityService.execStatus(id, currentStatus, ActivityStatus.CANCEL);
        return statusMap.get(currentStatus).activityCancel(id, currentStatus);
    }

}
